package cn.csc.module.distribute.dal.mysql.bank;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.module.distribute.controller.admin.bank.vo.BankInfoExportReqVO;
import cn.csc.module.distribute.controller.admin.bank.vo.BankInfoPageReqVO;
import cn.csc.module.distribute.dal.dataobject.bank.BankInfoDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 银行卡信息 Mapper
 *
 * @author liuchuang
 */
@Mapper
public interface BankInfoMapper extends BaseMapperX<BankInfoDO> {

    default PageResult<BankInfoDO> selectPage(BankInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BankInfoDO>()
                .eqIfPresent(BankInfoDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BankInfoDO::getAcctNo, reqVO.getAcctNo())
                .likeIfPresent(BankInfoDO::getAcctOpenBranchName, reqVO.getAcctOpenBranchName())
                .eqIfPresent(BankInfoDO::getPayee, reqVO.getPayee())
                .betweenIfPresent(BankInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BankInfoDO::getId));
    }

    default List<BankInfoDO> selectList(BankInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BankInfoDO>()
                .eqIfPresent(BankInfoDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BankInfoDO::getAcctNo, reqVO.getAcctNo())
                .likeIfPresent(BankInfoDO::getAcctOpenBranchName, reqVO.getAcctOpenBranchName())
                .eqIfPresent(BankInfoDO::getPayee, reqVO.getPayee())
                .betweenIfPresent(BankInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BankInfoDO::getId));
    }

    default BankInfoDO selectInfo(BankInfoDO reqVO) {
        return selectOne(new LambdaQueryWrapperX<BankInfoDO>()
                .eq(BankInfoDO::getUserId, reqVO.getUserId())
                .eq(BankInfoDO::getAcctNo, reqVO.getAcctNo()));
    }

}
